home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / Phrack / Phrack Issue 52.sit / Phrack52 / 52 / P52-08 < prev    next >
Text File  |  1998-01-26  |  35KB  |  785 lines

  1. ---[  Phrack Magazine   Volume 8, Issue 52 January 26, 1998, article 08 of 20
  2.  
  3.  
  4. -------------------------[  Steganography Thumbprinting
  5.  
  6.  
  7. --------[  The HackLab (http://www.hacklab.com)
  8.  
  9.  
  10.  
  11. Steg`a*nog"ra*phy (?), n. [Gr. covered (fr. to cover closely) +
  12.    -graphy.] The art of writing in cipher, or in characters which are not
  13.    intelligible except to persons who have the key; cryptography.  
  14.  
  15.  
  16. i. Introduction
  17.  
  18.     While this may be a general description of cryptography, steganography has
  19. come to describe not only the act of encrypting data, but also of hiding its
  20. very existence.  Steganography (or "stego") uses techniques to store a
  21. "message" file within a "container" file by altering the container file in
  22. such a way as to make the original file _appear_ unchanged.  The resulting
  23. file can be referred to as the stego file and contains the message file
  24. enclosed in a close approximation of the original container file.  Several
  25. tools exist (mostly for DOS/Windows/NT) which automate these functions using
  26. DES, DES3 or IDEA as encryption methods and BMP, GIF, JPG, WAV, VOC and even
  27. ASCII files as containers.  Using these tools, data can be hidden within
  28. images, sounds, and even other data files.  However, these tools do leave
  29. perceptible traces on their container files and do not offer nearly the
  30. level of obfuscation the user assumes.
  31.     
  32.     This article will provide the reader with a fundamental understanding of
  33. basic stego techniques and will highlight some of the "thumbprints" left by
  34. modern steganographic toolsets, specifically on graphic images.  Not intended
  35. to challenge the cryptographic strength or perceptible mathematical variances
  36. of current steganographic techniques, this article will give the reader a
  37. basic understanding of stego and suggest low-budget methods for detecting and
  38. cracking basic steganographic techniques.  Also presented is a program which
  39. can be used to brute-force two of the most popular stego toolsets.
  40.  
  41.  
  42. I. Basic Steganography
  43.  
  44.  
  45.     Simply put, steganography involves the hiding of messages.  While there are
  46. many techniques employed by the various tools, the least common denominator
  47. amongst most toolsets is the modification of some of the Least Significant
  48. Bits (or LSBs) of the container file's individual bytes.  In the simplest
  49. example, consider the following binary representations of the numbers 20
  50. through 27:
  51.  
  52. 10100 10101 10110 10111 11000 11001 11010 11011
  53.  
  54.     By modifying the LSBs of these binary digits, we can hide the binary
  55. representation of the number 200 (11001000) across the above bytestream:
  56.  
  57. 10101 10101 10110 10110 11001 11000 11010 11010
  58.  
  59.     By reconstructing the LSBs of the above bytestream, we recover the number
  60. 200 (11001000). In the above example, the original bytestream of the numbers
  61. 20-27 is the container, while the number 200 is the message file.  This is a
  62. very poor basic example since the resulting stego file is not an accurate
  63. representation of the original file.  After modification to include the
  64. message file, the numbers 20-27 now read:
  65.  
  66. 21 21 22 22 25 24 26 26
  67.  
  68.     However, in most stego applications, the container file does not contain
  69. bytestreams which are rendered useless by modifying LSB information.
  70. Instead, container files typically contain various levels of "noise" at the
  71. level of the LSB's which when viewed apart from the rest of the byte can
  72. appear random.  A sound (.WAV) file, for example contains mostly inaudible
  73. background noise at the LSB level.  An 8-bit graphic file will contain minor
  74. color differences at the LSB level, while a 24-bit image will contain color
  75. changes which are nearly imperceptible to the human eye.  A very common
  76. container format is a 256 color, 8 bit image such as a GIF or BMP file.
  77.  
  78.  
  79. II. Stego Techniques
  80.  
  81.  
  82.     In an 8-bit image such as a GIF or BMP each pixel is described as a number
  83. from 0 - 255 which refers to an actual color in the "color lookup table" or
  84. palette.  A common misconception is that all images simply contain strings of
  85. bytes that describe individual colors, and that the graphic file simply
  86. lists these colors in left-to-right, and top-to-bottom fashion.  This is
  87. only partially true for 8-bit images.  The palette lists every color that is
  88. used in the image (and extra colors, if less than 256 total colors are actually
  89. used in the image), and the image data itself is stored as a series of digits
  90. from 0 - 255 which reference an entry in the palette.  In this way, the image
  91. can be reconstructed by performing palette lookups to determine the color to
  92. insert at that pixel location.
  93.  
  94.     In order to hide data within an 8-bit GIF or BMP container, most existing
  95. tools use one of two techniques which I will term LSB palette reference
  96. modification and RGB element LSB modification.
  97.  
  98.     LSB palette reference modification involves changing the LSB(s) of a
  99. _palette_reference_ (0 - 255) in order to hide the data contained in the
  100. message.  Remember that a palette reference simply contains a number from 0 -
  101. 255 which references a color, or entry, in the palette.  In order to hide
  102. data, a program utilizing palette reference modification may decide which
  103. color to point to based on the color's LSBs.  This type of program will pay
  104. no attention to how similar the colors are, only whether or not the LSBs
  105. serve its purpose of data hiding.  If the adjacent colors in the palette have
  106. dissimilar LSBs, they are well suited for data hiding and become good
  107. candidates for storing hidden text in the final stegoed container.  If a 0
  108. (zero) is meant to be hidden, the stego program inserts the palette index
  109. reference of the color with the LSB of 0 (zero), and vice versa for hiding a
  110. 1 (one).
  111.  
  112.     RGB element LSB modification involves modifying the pixel's _actual_color_
  113. by changing the LSB of the Red, Green or Blue elements of the color in the
  114. color table.  For example, the color "white" is represented by the RGB values
  115. 255,255,255 which in binary equates to:
  116.  
  117. 11111111 11111111 11111111
  118.  
  119. listed in RGB order.  By altering the LSB of each color in the RGB element,
  120. we can hide data by making almost identical copies of colors such that only
  121. the LSBs are different.  Since the color is only changed by one or two LSBs,
  122. the resulting colors are very close, perhaps undetectable to the human eye.
  123. The result of this change to the colors in the table enables nearly identical
  124. colors to be referenced by multiple table entries.  This becomes extremely
  125. obvious when the palette is viewed and sorted by luminance (relative
  126. brightness)in a product such as Paint Shop Pro.  These similar colors will be
  127. grouped right next to each other in a luminance-sorted palette.  Using this
  128. technique, a binary 1 in the message file can be represented in the stego file
  129. by replacing a color in the container file with an altered version of that
  130. color whose RG or B element ends with a binary 1.  Likewise, a binary 0 in the 
  131. message file can be represented in the stego file by replacing the original
  132. color in the container file with an altered version of that color whose RG or 
  133. B element ends with a binary 0.
  134.  
  135.  
  136. III. Steganographic Thumbprints 
  137.  
  138.  
  139.     Several tools are available that apply these techniques to files on
  140. several different platforms.  I will focus on two specific toolsets; Steganos
  141. and S-Tools v4.0.  Steganos is perhaps the most versatile and powerful of the
  142. toolsets, while S-Tools seems to be the easiest and most widely used (not to
  143. mention the fact that I like S-Tools; it's been around for a long time and
  144. is very well done).  Other available toolsets include similar functionality
  145. and hiding techniques.  In order to discover what the tools actually do when
  146. they hide data, it's best to use a simple BMP container file.  The RGB BMP
  147. file utilizes a palette scheme identical to that of a GIF for the purposes
  148. of our tests, and all the reviewed toolsets can use BMP files as containers.
  149.  
  150.     For example, consider a container image which is 50 pixels by 50 pixels and
  151. contains only black-colored (0,0,0) pixels.  This image references palette
  152. entry 0 (zero) as its only color.  I will use a freeware painting program Paint
  153. Shop Pro V4.10 (PSP) to create and analyze the base images.  When creating 
  154. this image, PSP used a default palette with 216 unique palette entries and 40 
  155. "filler" entries at the end of the palette all of which contain the value 
  156. (0,0,0) or pure black.
  157.  
  158. Our message file is simply a text file which contains the phrase "This is a
  159. test."
  160.  
  161.  
  162. A. S-Tools
  163.  
  164.  
  165.     When the message file is hidden using S-Tools, the resulting 8-bit image
  166. appears identical to the human eye when compared to the original.  However,
  167. there are perceptible oddities about the file which are revealed under closer 
  168. scrutiny.
  169.  
  170.     Since S-Tools uses RGB element LSB modification as its hiding technique,
  171. the palette has distinct and very obvious characteristics.  Many of the
  172. palette's colors are offset by a single bit in the R,G or B element.  This is
  173. very obvious when the palette is sorted by luminance (brightness) and viewed
  174. with PSP.  The first sixteen (and only original) colors in this palette are:
  175.  
  176. (51,1,1) (51,1,0) (50,1,0) (51,0,1) (51,0,0) (50,0,1) (50,0,0) 
  177.  
  178. (1,1,0) (1,1,0) (0,1,1) (0,1,0) (1,0,1) (1,0,1) (1,0,0) (0,0,1) (0,0,0)
  179.  
  180.     Notice that the offsets of the RGB elements are only 1 bit.  This is an
  181. imperceptible color change, and is a very wasteful use of the palette.
  182. Remember, there are only 256 colors to work with.  Most 8-bit image creation
  183. programs are very careful when deciding which colors to include in the palette,
  184. and almost all use standard palettes which contain all the most commonly used
  185. colors.  To see a palette with this many _nearly_ identical colors is odd.
  186. Also, the palette has been adjusted to contain less colors. The standard 
  187. colors selected by PSP have been replaced by some of the colors listed above.
  188. As is typical with this type of hiding, the slack space at the end of the
  189. palette has been reduced to make room for the new copies of existing colors.
  190. This type of hiding will always make itself obvious by using single-bit
  191. offsets in one or more of the LSBs.  Since this type of thumbprint is so
  192. easily identifiable, we will concentrate our efforts on the harder-to-detect
  193. palette reference method used by Steganos.
  194.  
  195.  
  196. B. Steganos
  197.  
  198.  
  199.     Steganos kindly reminds you that 8-bit images don't make terribly secure
  200. containers.  It's a good thing, too, because when the message file is hidden
  201. using Steganos the resulting 8-bit image has a major anomaly- the stego
  202. image is completely different than the original!  As opposed to an all-black
  203. image, the image now resembles a black-and-blue checkerboard.  However, this
  204. difference is only obvious if you have access to the original image.  Since
  205. an interceptor will most likely not have a copy of the original image, we
  206. will examine other methods of detection.  When the palette of the image is
  207. checked for single-bit offset colors (as in the stego image created with
  208. S-Tools), none can be found.  Also, there is no more or less slack space at
  209. the end of the palette than existed in the original palette.  Steganos does
  210. not alter the palette in any way when hiding data.  It uses the LSB palette
  211. reference technique described above.  However, there are very distinctive
  212. ways of determining if this technique has been used to hide data, specifically
  213. by looking at _how_ the palette's colors are used.  In this simple case, a
  214. histogram will show exactly the type of modification we are looking for.
  215. In the words of the PSP Help documentation,
  216.  
  217. "A histogram is a graph of image color values, typically RGB values and/or
  218. luminance.  In a histogram, the spectrum for a color component appears on the
  219. horizontal axis, and the vertical axis indicates the portion of the image's
  220. color that matches each point on the component's spectrum."
  221.  
  222.     In a nutshell, this simply means a graph is generated showing how the
  223. color(s) are used in an image, and how similar (in shade) they are.  When
  224. viewing the "blue" histogram for the Steganos-hidden file, we see something
  225. like this:
  226.  
  227. 100= X                   X
  228.    - X                   X
  229. 90 = X                   X
  230.    - X                   X
  231. 80 = X                   X
  232.    - X                   X
  233. 70 = X                   X
  234.    - X                   X
  235. 60 = X                   X
  236.    - X                   X
  237. 50 = X                   X
  238.    - X                   X
  239. 40 = X                   X
  240.    - X                   X
  241. 30 = X                   X
  242.    - X                   X
  243. 20 = X                   X
  244.    - X                   X
  245. 10 = X                   X
  246.    - X                   X
  247. 00 = X                   X 
  248.   . ! . ! . ! . ! . ! . ! . ! . ! . ! . ! . . . 
  249.     0   1   2   3   4   5   6   7   8   9       2
  250.     0   0   0   0   0   0   0   0   0   0       5     
  251.                                                 5
  252.  
  253.     The X-axis shows the spectrum for the color blue (from 0 to 255).  The
  254. Y-axis shows the number of pixels in the image that match that color.  When
  255. displaying a histogram, the 100 on the Y axis is not percentage, but a MAX
  256. value (in this case 1272) which indicates the greatest number of pixels used
  257. for _any_one_color_.  Since there are really only two colors _used_ in this
  258. stego image, there are only two vertical bars.  These bars indicate that in
  259. the Blue color family there are really only two colors used; one with a blue
  260. value of zero, and another with a blue value of approximately 50 (51 to be
  261. exact).  Upon examining the color table for this image sorted in
  262. _palette_order_, it is evident that these two referenced colors are only
  263. similar since they are placed right next to one another in the palette.  The
  264. two colors are (0,0,0) and (0,0,51) or black and very, very dark blue.  The
  265. image mostly has black hues, and Steganos probably picked the very dark blue
  266. color (00110011) as the 1 for some hidden data, and black (00000000) as the
  267. 0 for some hidden data since these colors are _right_ next to each other in
  268. a palette-index-order color table listing.  Although they reside next to each
  269. other in the palette, the colors are not very similar which makes the final
  270. stego file appear discolored.  Steganos does not modify any of the colors,
  271. but it modifies how the original palette is used by making nearly equal
  272. references to a color and its neighbor (when sorted by palette index).
  273. Bottom line: this image uses neighboring palette colors nearly an identical
  274. number of times.  1272 pixels were used for black and 1228 pixels were used
  275. for the dark, dark blue.  This would not be unusual if not for the fact that
  276. the colors are palette index neighbors.  If the designer of the image were
  277. using some sort of shading effect, there would be many more than just two
  278. shades involved in this 256 color image, and the shading offsets would be
  279. greater.  These two colors don't even appear as shades of one another when
  280. placed side-by-side.
  281.  
  282.     A skilled interceptor will know immediately that something is not quite
  283. right with these images.  They both display typical signs of data hiding.
  284.  
  285.  
  286. IV.  Real-World example
  287.  
  288.  
  289.     Intercepting a single-color image and determining that it is stegoed is a
  290. trivial task.  Increasing the number of used colors within the boundaries of
  291. the 256-color palette could (so the reader may think) obfuscate the hidden
  292. message file.  However, by applying a few simple methodologies, a pattern
  293. emerges which can increase the odds of detecting a stegoed image.  For
  294. example, if a two-color image is created using only the colors black (0,0,0)
  295. and white (255,255,255), and data is hidden in the file by using Steganos,
  296. the results would show that Steganos not only used black and white, but two
  297. more colors from the palette are used with values of (0,0,51) and
  298. (255,255,51) respectively.  These newly-used colors adjoin the original two
  299. colors in the palette listing, have differing LSBs, and are referenced
  300. nearly as much in the new image as the original colors are.  A similar
  301. situation evolves when a 6-color image is created.  After Steganos hides the
  302. data, the original 6 colors and their palette neighbors will be used in
  303. the new file.  The 6 new colors become alternate representations of the
  304. original 6 colors in terms of their LSBs.  This methodology holds true all
  305. the way up to images containing 256 different colors.  By understanding these
  306. patterns, all 8-bit Steganos images can be detected without access to the
  307. original image.
  308.  
  309.     When attempting to detect the use of steganography in 16 or 24-bit images,
  310. a great deal of pattern analysis must be used.  24-bit stego detection is not
  311. for the faint of heart, but it can be done.  Standard "randomization" solutions
  312. fall quite short of solving this problem since LSB data in image creation
  313. programs is hardly random.  It follows a pronounced pattern when viewed as a
  314. part of a whole: an 8-bit number.  Most standard graphics effects do not use
  315. random data, they use patterns to create and maintain a certain graphic
  316. illusion.  Inserting "random" data, even at the LSB level can become fuel for
  317. the analyst's fire.  In many 24-bit stego programs, bits in the secret text
  318. are generally inserted with average spacing between them, then random "noise"
  319. is added to make the secret bits seem less obvious.  The random "noise" would 
  320. (should!) have a random interval between differing bits.  The contrast of an
  321. average spacing against random spacing may be enough to not only alert an
  322. analyst, but to point out where secret bits start and random bits begin.  The
  323. bottom line is that 24-bit detection is doable, just not practical for an
  324. amateur- yet!
  325.  
  326.  
  327. V.  The Future
  328.  
  329.  
  330.     Steganography is in it's infancy, but several new technologies are emerging
  331. including selection and construction methods of data hiding and continuing
  332. research in the area of random distribution.
  333.  
  334.     Selection involves the generation of a large number of copies of the same
  335. container file that differ slightly.  In the case of an image file, you may
  336. make minor adjustments in hue, saturation and RGB levels to the end that your
  337. secret message will eventually _appear_ in the LSBs of the data!  Although
  338. difficult to generate, this type of data hiding is nearly impossible to detect
  339. since the image's characteristics are not altered at all.
  340.  
  341.     Construction simply involves modeling the characteristics of the original
  342. container when creating your message.  In simplest terms, mold your message
  343. around the existing container instead of molding the container to your message.
  344. If, for example the original image were left unchanged, and a key was
  345. developed to create the message _from_ the image, detection would be impossible
  346. without the key.
  347.  
  348.     Several advances are being made in the area of random distribution,
  349. specifically by Tuomas Aura at the Helsinki University of Technology.  His
  350. paper "Practical Invisibility in Digital Communication" presents a technique
  351. called "pseudorandom permutation", which brings steganography up to the
  352. technical level of cryptography and properly addresses the issue of
  353. randomness from a data hiding perspective.  His paper is excellent reading
  354. and can be found at http://deadlock.hut.fi/ste/ste_html.html
  355.  
  356.     Interesting research (and proof-of-concepts) are being done to utilize
  357. stego techniques in reserved fields in TCP, UDP and ICMP packets.  This
  358. research proves that steganography has merit and application beyond sound and
  359. image files.  Unfortunately, using stego where there was nothing before (ie 
  360. within typically blank reserved fields) can raise a flag in and of itself.  Use
  361. encryption and compression to further protect data.  It really doesn't matter
  362. if the secret data is discovered if the underlying crypto is secure.
  363.  
  364.  
  365. VI. Conclusion
  366.  
  367.  
  368.     Detecting stego in an 8-bit image is fairly easy.  Actually gaining access
  369. to the secret text becomes a bit harder yet a simple overlooked method involves
  370. bruteforcing the creating application (see S_BRUTE.WBT program below).  On the
  371. other hand, 24-bit image analysis requires quite a bit of work.  If you choose
  372. to employ data hiding techniques, use 24-bit images and compress and encrypt
  373. your message file, bearing in mind that 24-bit images can raise flags simply
  374. due to their size.
  375.  
  376. When attempting to identify stego files in 8-bit images, keep in mind the
  377. following pointers: 
  378.  
  379. * Search for the obvious thumbprint of an RGB element.
  380. * In the stego file: single-bit offsets between colors in a palette sorted by 
  381.   luminance (this SCREAMS S-Tools!).
  382. * If no single-bit offsets exist between the colors in the palette, search
  383.   for Palette Reference thumbprints which include the following:
  384. * Use of palette index neighbors a near-equal number of times either in the
  385.   entire image (use a histogram) or in an area which should be primarily
  386.   single-color only but contains a checkerboard effect (use zoom 11:1 to see
  387.   individual pixels, and the eyedropper tool to quickly view the RGB
  388.   elements in PSP)
  389. * Poor image quality (noise and snow are common side-effects).
  390. * For more detailed analysis the reader might consider using an MS-DOS 
  391.   program msgifscn.zip, available from Simtel mirror sites worldwide, to
  392.   dump the entire contents of an 8-bit GIF image's palette to a file, which
  393.   can be dumped into MS Excel for analysis (the analysis add-in in for Excel
  394.   comes in REAL handy for binary conversions and data sorts.)
  395. * If you have a clue that the file you're looking at may contain stegoed 
  396.   data, it never hurts to brute force the application that created it! (see
  397.   the S_BRUTE program listing at the end of this article) While this may be
  398.   one of the slower methods of breaking stego, it is often easier to
  399.   derive possible keyphrases from other sources than attacking the stego
  400.   algorithm or the crypto.
  401.  
  402.  
  403. VII.  The program
  404.  
  405.     The author of S-Tools sells the source code for his program, and Steganos
  406. makes available an SDK for hiding/decoding files using it's algorithms, but
  407. an option exists for programs that do not make their source available:
  408. bruteforce of the application itself.  Although using the API and SDK's
  409. available would be significantly faster, there are times when this option
  410. just may not exist.
  411.  
  412.     To that end, included below are two files, S_BRUTE.WBT and S_BRUTE.INI.
  413. This program was written in WinBatch, which is a language that acts very much
  414. like the UNIX language TCL/TK (or Expect), but operates in a Windows 95/NT
  415. context.  Developed to control Windows applications, WinBatch provides a
  416. perfect vehicle for brute-forcing an application's password function (see
  417. http://www.windowware.com for the free compiler to run S_BRUTE). S_BRUTE is
  418. an application that will bruteforce S-Tools v4 and Steganos using a
  419. dictionary file in an attempt to determine the passphrase of a stegoed image
  420. (which will subsequently reveal the hidden text). The program selects which
  421. tool to use based on which executable you select, and the S-Tools portion of
  422. the program will not only bruteforce the passphrase, but will attempt all
  423. four algorithms available to S- Tools.  Unfortunately S-Tools uses certain
  424. mouse-only operations, so you will effectively lose your mouse while the
  425. S-Tools portion runs.  The dictionary needed by this program is simply a list
  426. of words or passphrases separated by newlines.  Keep in mind that Steganos
  427. does not allow passwords shorter than five characters, so strip those out to
  428. save time.  If you need to use a " (double-quote) in the word/passphrase,
  429. simply use "" (two double quotes) in the dictionary.  WinBatch likes this.  A
  430. log file is created as c:\output.txt which simply lists all the attempted
  431. words/passphrases.  The output file can be reused as a dictionary since no
  432. extraneous information is written out.  Two options exist for inputting the
  433. names of the Stego tool executable, the dictionary file and the stego image.
  434. The S_BRUTE.INI file format (see below) allows the variables exepath, dict
  435. and stegofile which allow the input of these full path names into the
  436. program.  In addition, the program can prompt for the filenames manually
  437. using standard Windows '95 file boxes.  In this case, pay attention to the
  438. box titles as they come up.  These titles describe what file the program is
  439. looking for.  A variable is also available in the INI file called
  440. STEGANOSDELAY.  This value (listed in seconds) determines how long to wait
  441. for a passphrase error message from Steganos.  The default is 0, but if you
  442. get a lot of false positives (your machine is SLOW!) set this value to a few
  443. seconds.  Due to the speed of the bruteforce attack, this program is not
  444. always accurate as to _which_word_ actually worked if it finds a match.  In
  445. this case, S_BRUTE will tell you which word it _thinks_ worked, but you may
  446. have to try the word S_BRUTE gave you plus one or two of the previous words
  447. in c:\output.txt (plus a few different algorithms if you're using S-Tools).
  448. Either way, you are only looking at about 12 combinations (not bad!).
  449.  
  450.     Note that S-Tools and/or Steganos must be properly installed prior to using
  451. this program.  S_BRUTE was not designed to brute force the entire keyspace, but
  452. to give you a faster method of determining the passphrase if you have any idea
  453. what it might be.  If the stego image is found on a web page, create a
  454. dictionary from words and phrases found on that site, and let S_BRUTE do the
  455. work for you.
  456.  
  457. <++> sbrute/S_BRUTE.WBT
  458. ;; Steganography Brute v1.0 written by a researcher at hacklab.com 
  459. ;; For new versions and support programs see http://www.hacklab.com
  460. ;; This little toy brute forces two very common Steganography utilities, 
  461. ;; specifically Steganos (http://www.steganography.com) and S-Tools written 
  462. ;; by Andrew Brown (a.brown@nexor.co.uk) 
  463. ;; This program can be run using a free program called WinBatch 
  464. ;; from http://www.windowware.com
  465. ;;
  466. ;;
  467. ;;Notes:
  468. ;;
  469. ;; 1) The program depends on the executable name being either "S-TOOLS.EXE" or
  470. ;;    "STEGANOS.EXE". This exe name decides many things, including the
  471. ;;    semantics of the brute force attack and which types of container files
  472. ;;    to accept. (Remember that the tools accept different types of container 
  473. ;;    files.)
  474. ;; 2) The dictionary file is simply a text file with words or phrases separated
  475. ;;     by CR(LF). If a " (double quote) must be used in the word or phrase, 
  476. ;;    use "" (two double quotes) instead. This is Winbatch's way of representing
  477. ;;     the double quote in a string.
  478. ;; 3) Internally, this program converts all Windows LFN-formatted dir/filenames to
  479. ;;    DOS-style 8.3 or short dir/filenames. If you have problems, finding/using
  480. ;;    LFN files, you may want to manually convert them to a SFN dir/file structure.
  481. ;; 4) The S-Tools test requires certain mouse-only operations. During this part of
  482. ;;    the program, it's best to leave your machine alone. Otherwise the mouse will
  483. ;;    be all over the place. Sorry. 
  484.  
  485. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  486. :main                         ;;
  487. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  488.  
  489.  
  490. Intcontrol(12,4,0,0,0)         ;;controls abrupt endings
  491.  
  492. if (winmetrics(-4) < 4 ) 
  493.         error="This program runs on Windows NT or Windows '95 only!"
  494.         gosub bail_error
  495. EndIf
  496.  
  497. cr=Num2Char(13)
  498. lf=Num2Char(10)
  499. crlf=StrCat(cr, lf)
  500. progname="Steganography Brute"
  501. STEGANOS=0            ;; Flag for Steganos
  502. STOOLS=0            ;; Flag for S-Tools
  503.     
  504.  
  505.  
  506. text1='This program brute forces Steganography programs.'
  507. text2='Including S-Tools v4.0 and Steganos. Do you wish'
  508. text3='to continue?'
  509. ;q = AskYesNo('%progname%',"%text1% %crlf% %text2% %crlf% %text3%")
  510. If (AskYesNo('%progname%',"%text1% %crlf% %text2% %crlf% %text3%")  == @NO) Then Exit
  511.  
  512. text1="It is easiest to make all file settings through the"
  513. text2="S_BRUTE.INI file in this directory. If you do not use"
  514. text3="this file, you will be manually prompted for the files."
  515. Text4="Do you wish to use the INI file?"
  516. q= AskYesNo("%progname%"," %text1% %crlf% %text2% %crlf% %text3% %crlf% %text4%")
  517.  
  518. if (q  == @NO) Then gosub prompt_for_files
  519. else gosub set_files
  520.  
  521.  
  522. if (STEGANOS) 
  523.     gosub steganos
  524. else 
  525.     if (STOOLS) then gosub stools
  526. EndIf
  527.  
  528. error="Passphrase not found!"
  529. gosub bail_error
  530.  
  531. Exit
  532.  
  533.  
  534.  
  535. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  536. :steganos                 ;;;
  537. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  538. Run("%exepath%", "%stegofile%")
  539. WinWaitExist("",10)        ;;; Steganos' first window has no title. 
  540.                ;;; If you have problems,
  541. SendKeysTo("","{ENTER}")   ;;; comment out these two lines...
  542. ;TimeDelay(10)             ;;; and uncomment...
  543. ;SendKey("{ENTER}")        ;;; these two lines.
  544.  
  545.  
  546. WinWaitExist("Steganos for Windows 95",30)
  547. SendKeysTo("Steganos for Windows 95","{ENTER}")
  548.  
  549. dictgrip=FileOpen("%dict%","READ")
  550. fn1="c:\output.txt"
  551. handleout=FileOpen("%fn1%","Append")
  552. stitle="Steganos for Windows 95"
  553. START_TIME=TimeYmdHms()
  554. word=0
  555.  
  556. while (word != "*EOF*")            
  557.    word = FileRead(dictgrip)
  558.    if word =="" then continue
  559.    if word =="*EOF*" then break
  560.    ClipPut("%word%")
  561.    SendKeysTo(stitle,"^v{ENTER}")
  562.    TimeDelay(STEGANOSDELAY)
  563.    test=strsub(MsgTextGet(stitle),1,22)
  564.    if test=="" 
  565.     text1="I think we have a match!"
  566.     text2="Due to the speed of the brute force attack, check c:\output.txt"
  567.     text3="to see the last few words used, but I think the passphrase is:"
  568.     text4="%word%"
  569.     success="%text1% %crlf%%text2% %crlf%%text3% %crlf%%text4%"
  570.     gosub bail_success
  571.    else
  572.     if test=="This password is wrong"
  573.        SendKeysTo(stitle,"{ENTER}")
  574.        SendKeysTo(stitle,"!B{ENTER}")
  575.        FileWrite(handleout,"%word%" )
  576.     endif
  577.    endif
  578. endwhile
  579. STOP_TIME=TimeYmdHms()
  580.  
  581. FileClose(dictgrip)
  582. FileClose(handleout)
  583.  
  584. Return
  585.  
  586. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  587. :stools                  ;;;
  588. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  589. Run("%exepath%", "%stegofile%")
  590. if (WinWaitExist("Welcome to S-Tools",5) == @TRUE) 
  591.     SendKeysTo("Welcome to S-Tools","!C")
  592. EndIf
  593.  
  594.     winplace(0,0,400,400,"~S-Tools")
  595.     WinWaitClose("Please Wait")
  596.     SendMenusTo("~S-Tools", "Window Tile Horizontally")
  597.  
  598. text1="S-Tools requires certain mouse-only operations."
  599. text2='After clicking OK, position the mouse within your'
  600. text3="image in the S-Tools window and click the left button."
  601.  
  602. message("Setup mouse for S-Tools","%text1% %crlf% %text2% %crlf% %text3%")
  603.  
  604. while (mouseinfo(4)!="4")
  605.     magic=mouseinfo(2)
  606. endwhile
  607.  
  608. magicx=( ItemExtract(1,magic," ") )
  609. magicy=( ItemExtract(2,magic," ") )
  610.  
  611.  
  612. dictgrip=FileOpen("%dict%","READ")
  613. fn1="c:\output.txt"
  614. handleout=FileOpen("%fn1%","Append")
  615.  
  616. START_TIME=TimeYmdHms()
  617. word=0
  618. while (word != "*EOF*")            
  619.         word = FileRead(dictgrip)
  620.         if word =="" then continue
  621.     ClipPut("%word%")
  622.  
  623.     ;;;  write to the output file
  624.     if word!="*EOF*" 
  625.         if (FileWrite(handleout,"%word%" ) >0)
  626.             error="Unable to open file %fn1%."
  627.             gosub bail_error
  628.         EndIf
  629.     Endif
  630.         
  631.     for dumnum=1 to 4      ;; for all the algorithms 
  632.         
  633.      MouseMove(magicx, magicy, "","")
  634.      MouseClick(@RCLICK, 0)
  635.      SendKeysTo("~S-Tools","r")
  636.      SendKeysTo("~Revealing","!P^v!V^v!E")
  637.  
  638.      if (dumnum==1) then SendKeysTo("~Revealing","I")   ;; IDEA
  639.      if (dumnum==2) then SendKeysTo("~Revealing","D")   ;; DES
  640.      if (dumnum==3) then SendKeysTo("~Revealing","T")   ;; DES3
  641.      if (dumnum==4) then SendKeysTo("~Revealing","M")   ;; MDC
  642.      SendKeysTo("~Revealing","{ENTER}")
  643.      ;childlist=WinItemChild("~S-Tools")
  644.      numchilds= ItemCount(WinItemChild("~S-Tools"), @TAB)
  645.  
  646.      if (numchilds>2)
  647.       text1="We have an extra window in S-Tools! Possible passphrase match."
  648.       text2="Due to the speed of the brute force attack, check c:\output.txt"
  649.       text3="to see the last few words used, but I think the passphrase is:"
  650.       text4="%word%"
  651.        success="%text1% %crlf%%text2% %crlf%%text3% %crlf%%text4%"
  652.       gosub bail_success
  653.      endif
  654.        next
  655.  
  656. endwhile
  657.  
  658. FileClose(dictgrip)
  659. FileClose(handleout)        
  660.  
  661. return
  662.  
  663.  
  664.  
  665. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  666. :set_files                    ;;
  667. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  668. fname=IniReadPvt("Main", "exepath", ".\S-TOOLS.EXE", ".\S_BRUTE.INI")
  669. gosub path_clean
  670. exepath=fname
  671.  
  672. gosub determine_tool_type
  673.  
  674. fname=IniReadPvt("Main", "dict", ".\DICT.TXT", ".\S_BRUTE.INI")
  675. gosub path_clean
  676. dict=fname
  677.  
  678. fname=IniReadPvt("Main", "stegofile", ".\STEGO.GIF", ".\S_BRUTE.INI")
  679. gosub path_clean
  680. stegofile=fname
  681.  
  682. STEGANOSDELAY=IniReadPvt("Main","STEGANOSDELAY","0",".\S_BRUTE.INI")
  683.  
  684. gifname= ItemExtract( (ItemCount("%stegofile%", "\")), "%stegofile%", "\")
  685.  
  686. Return
  687.  
  688. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  689. :prompt_for_files             ;;
  690. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  691. msg = "Enter the Steganos error delay 0-60"
  692. STEGANOSDELAY=AskLine("%progname%", msg ,"0")
  693.  
  694. types="Dictionary Text Files|*.txt|All Files|*.*|"
  695. dict=AskFileName("Select Dictionary Filename", "C:\", types, "dict.txt", 1)
  696. dict=FileNameShort(dict)
  697.  
  698. types="Steganography tool Executable|*.exe|"
  699. msg="Where is the S-Tools or Steganos executable?"
  700. exepath=AskFileName(msg, "C:\", types, "", 1)
  701. exepath=FileNameShort(exepath)
  702.  
  703. gosub determine_tool_type
  704.  
  705. if (STEGANOS)
  706.   types="Stego File (with hidden message)|*.bmp;*.dib;*.voc;*.wav;*.txt;*.html|"
  707. else
  708.   types="Stego File (with hidden message)|*.gif;*.bmp;*.wav|"
  709. endif
  710.  
  711. text1="Select Stego Filename (containing hidden message)"
  712. stegofile=AskFileName("%text1%", "C:\", types, "", 1)
  713. stegofile=FileNameShort(stegofile)
  714. gifname= ItemExtract( (ItemCount("%stegofile%", "\")), "%stegofile%", "\")
  715. Return
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  724. :path_clean                   ;;
  725. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  726. switch FileExist(fname)
  727.     case 0    
  728.         error="File %fname% not found!"
  729.         gosub bail_error
  730.         break
  731.     case (2)
  732.         error="File %fname% in use!"
  733.         gosub bail_error
  734.         break
  735. endswitch
  736. fname=FileNameShort(fname)
  737. Return
  738.  
  739.  
  740. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  741. :determine_tool_type          ;;
  742. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  743. exename=(StrUpper(ItemExtract( (ItemCount("%exepath%", "\")), "%exepath%", "\")))
  744.  
  745. if (exename == "S-TOOLS.EXE") then STOOLS=1
  746. else if (exename == "STEGANOS.EXE") then STEGANOS=1
  747. Return
  748.  
  749.  
  750. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  751. :bail_error                   ;;
  752. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  753. STOP_TIME=TimeYmdHms()
  754. Message("%progname% Error!","%error%")
  755. SECONDS=TimeDiffSecs(STOP_TIME,START_TIME)
  756. Message("%progname%","Finished in %SECONDS% seconds.")
  757. Exit
  758.  
  759. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  760. :bail_success                 ;;
  761. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  762. STOP_TIME=TimeYmdHms()
  763. Message("%progname% Success!!!","%success%")
  764. Message("%progname%","Time Started: %START_TIME%%crlf%Time Finished: %STOP_TIME%")
  765. Exit
  766.  
  767. <-->
  768. <++> sbrute/S_BRUTE.INI
  769. [Main]
  770.  
  771. EXEPATH="C:\Program Files\Deus Ex Machina\Steganos\Steganos.exe"
  772. DICT="C:\win\desktop\dict.txt"
  773. STEGOFILE="C:\win\desktop\steclouds.bmp"
  774. ;STEGOFILE="C:\win\desktop\s-tclouds.gif"
  775. STEGANOSDELAY=0    ;; Set this higher for false positives.
  776.             ;; (Steganos does not use different names for its
  777.             ;; windows, so this program makes negative result
  778.             ;; checks (ie bad passwords) based on an error dialog.
  779.             ;; This timeout controls how many seconds to wait for 
  780.             ;; an error. Default=0
  781.  
  782. <-->
  783. ----[  EOF
  784.  
  785.